import request from '@/utils/request'

const baseUrl = '/admin/api/v1/role'

/**
 * 查询所有角色列表
 */
export const getRoleList = () => {
  return request.get(`${baseUrl}/list`)
}

/**
 * 根据ID查询角色详情
 */
export const getRoleById = (id) => {
  return request.get(`${baseUrl}/${id}`)
}

/**
 * 创建角色
 */
export const createRole = (data) => {
  return request.post(baseUrl, data)
}

/**
 * 更新角色
 */
export const updateRole = (id, data) => {
  return request.put(`${baseUrl}/${id}`, data)
}

/**
 * 删除角色
 */
export const deleteRole = (id) => {
  return request.delete(`${baseUrl}/${id}`)
}

/**
 * 分配权限给角色
 */
export const assignPermissions = (id, permissionIds) => {
  return request.put(`${baseUrl}/${id}/permissions`, { permissionIds })
}

